import request from '@/utils/request'
import { AxiosPromise } from 'axios'

enum Api {
  list = '/customer/list',
  add = '/customer/add',
  update = '/customer/update',
  delete = '/customer/delete',
  batchDelete = '/customer/batchDelete',
  detail = '/customer/getDetail',
  topup = '/customer/topup',
  batchRestore = '/customer/batchRestore',
}

// 获取列表
export const getCustomerList = (data: any): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const saveCustomer = (data: any) => {
  return request({
    url: data.id ? Api.update : Api.add,
    method: 'post',
    data,
  })
}

// 删除
export const deleteCustomer = (data: string) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}
// 批量删除
export const batchDeleteCustomer = (data: (string | number)[]) => {
  return request({
    url: Api.batchDelete,
    method: 'post',
    data,
  })
}

// 详情
export const getDetail = (data?: string) => {
  return request({
    url: Api.detail,
    method: 'post',
    data,
  })
}

// 充值
export const topup = (data: any) => {
  return request({
    url: Api.topup,
    method: 'post',
    data,
  })
}

// 批量重新结算
export const batchRestoreCustomer = (data: (string | number)[]) => {
  return request({
    url: Api.batchRestore,
    method: 'post',
    data,
  })
}
